package org.iteam.mina.message;

import java.io.Serializable;

/**
 * 通用基本消息结构
 * 
 * @author 王大侠
 *
 */
public class BaseMessage implements Serializable {
	private static final long serialVersionUID = -3502059727406773704L;
	protected int length = 0;// 消息总长度(含消息头及消息体)
	protected int cmd;// 消息命令或响应
	protected int rule = 0x00000000;// 消息规则
	protected int ver = 0x00000000;// 消息版本
	protected String seq;// 消息流水号,32位UUID字符串

	protected String token;// 令牌,32位UUID字符串
	protected byte[] content;// 消息内容数据
	protected byte[] verify;// 校验信息，RSA签名或HMAC校验位

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public int getCmd() {
		return cmd;
	}

	public void setCmd(int cmd) {
		this.cmd = cmd;
	}

	public int getRule() {
		return rule;
	}

	public void setRule(int rule) {
		this.rule = rule;
	}

	public int getVer() {
		return ver;
	}

	public void setVer(int ver) {
		this.ver = ver;
	}

	public String getSeq() {
		return seq;
	}

	public void setSeq(String seq) {
		this.seq = seq;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public byte[] getContent() {
		return content;
	}

	public void setContent(byte[] content) {
		this.content = content;
	}

	public byte[] getVerify() {
		return verify;
	}

	public void setVerify(byte[] verify) {
		this.verify = verify;
	}

	public String toString() {
		return "BaseMessage [token=" + token + ",version=" + String.format("0x%1$08x", ver) + ", rule=" + String.format("0x%1$08x", rule) + ", cmd="
				+ String.format("0x%1$08x", cmd) + ", sequence=" + seq + ", length=" + length + ", content=" + content + ", verify=" + verify + "]";
	}
}
